<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="author" content="Mr.郭/QQ:1007694939">
    <title>会员注册</title>
    <!--引入Font Awesome字体库样式表-->
    <link rel="stylesheet" href="/static/css/font-awesome.min.css"
          tppabs="http://demo.demohuo.top/modals/63/6398/demo//static/css/font-awesome.min.css">
    <!--引入guojian.min.css组件样式表-->
    <link rel="stylesheet" href="/static/css/guojian.min.css"
          tppabs="http://demo.demohuo.top/modals/63/6398/demo//static/css/guojian.min.css">
    <!--引入style.css自定义样式表-->
    <link rel="stylesheet" href="/static/css/style.css"
          tppabs="http://demo.demohuo.top/modals/63/6398/demo//static/css/style.css">
    <script src="/static/js/jquery-1.12.4.min.js"></script>
    <script>
        $.ajaxSetup({
            data: {csrfmiddlewaretoken: '{{ csrf_token }}'}
        })
    </script>
</head>

<body>

<div class="gj-dlzc">
    <h3><img src="/static/picture/logo2.png"
             tppabs="http://demo.demohuo.top/modals/63/6398/demo//static/picture/logo2.png" alt=""></h3>
    <h5>会员登陆:</h5>
    <form action="" method="post">
        <input type="hidden" name="referer" value="">
        <table cellpadding="0" cellspacing="1">
            <input type="hidden" name="csrfmiddlewaretoken" value="{{ csrf_token }}">
            <input type="password" required="" name="old_password" id="old_password" value="" placeholder="请输入原密码">
            <input type="password" required="" name="password" onblur="Password()" id="password" value="" placeholder="请输入新密码">
            <span id="span_pwd">请输入8-20个字符</span>
            <input type="password" required="" name="password2" onblur="Password2()" id="password2" value="" placeholder="请重复新密码">
            <span id="span_pwd2">请输入8-20个字符</span>
            <div class="gjdl-zc">
                <button type="button" name="dosubmit" id="sub" value="登录">修改</button>
            </div>
        </table>
    </form>
    <div class="gjdl-sx">
        <a href="init.html" tppabs="http://demo.demohuo.top/modals/63/6398/demo/init.html" role="button"
           target="_blank">忘记密码？</a>
        <a href="register.html" tppabs="http://demo.demohuo.top/modals/63/6398/demo/register.html"><i class="fa fa-user"
                                                                                                      aria-hidden="true"></i>
            免费注册</a>
        <a href="qq_login.html" tppabs="http://demo.demohuo.top/modals/63/6398/demo/qq_login.html"><i class="fa fa-qq"
                                                                                                      aria-hidden="true"></i>
            QQ登录</a>
    </div>
    <a href="index.html" tppabs="http://demo.demohuo.top/modals/63/6398/demo/index.html" class="fan">返回首页</a>
    <p>Powered by YzmCMS</p>
</div>


<script type="text/javascript">
    $('#sub').click(function () {
        $.ajax({
            url: "/password/",
            type: "post",
            dataType: 'json',
            {#headers: {"X-CSRFToken": $.cookie('csrftoken')},#}
            data: {
                old_password: $("#old_password").val(),
                password: $("#password").val(),
                password2: $("#password2").val(),
            },
            success: function (data) {
                if (data.code_s == 0) {
                    alert(data.errmsg);
                    window.location = '/'
                } else {
                    alert(data.errmsg);
                    window.location = '/'
                }
                {#$(".ret").val(data)#}
            }
        })
    });

    function Password() {
        //密码
        var pwd = document.getElementById("password").value;
        var reg = /^[\d\w]{8,20}$/;
        if (!reg.test(pwd)) {
            span_pwd.innerHTML = "请输入5-20以内数字、字母或组合密码";
        } else {
            span_pwd.innerHTML = "格式正确";
        }
    }

    function Password2() {
        //确认密码
        var pwd = document.getElementById("password").value;
        var pwd2 = document.getElementById("password2").value;
        if (pwd != pwd2) {
            span_pwd2.innerHTML = "两次输入不一致";
        } else {
            span_pwd2.innerHTML = "格式正确";
        }
    }

</script>
</body>

</html>